package com.uenpay.im.ui.old.activity.red;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.uenpay.im.IMApplication;
import com.uenpay.im.R;
import com.uenpay.util.app.base.BaseActivity;

/**
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class RedActivity extends BaseActivity {

    private LinearLayout forward_success_layout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        isFullScreen = true;
        super.onCreate(savedInstanceState);
    }

    @Override
    public View bindView() {
        return null;
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_red_layout;
    }

    @Override
    public void initView(View view) {
        initView();
        initListener();
    }

    protected void initView() {
        forward_success_layout = (LinearLayout) findViewById(R.id.forward_success_layout);
        ((TextView) findViewById(R.id.title_textview)).setText(getResources().getString(R.string.red));
        ((TextView) findViewById(R.id.title_right_tv)).setText(getResources().getString(R.string.red_my_red));
        findViewById(R.id.title_right_layout).setVisibility(View.VISIBLE);
    }

    protected void initListener() {
        findViewById(R.id.title_right_layout).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {

                Intent intent = new Intent(RedActivity.this, ReceviedOrSendRedActivity.class);
                intent.putExtra("type", 1);
                startActivity(intent);

                // BottomDialog.showBottomRedDialog(RedActivity.this,
                // new OnBottomDialogListener() {
                //
                // @Override
                // public void onClicked() {
                // Intent intent = new Intent(
                // RedActivity.this,
                // ReceviedOrSendRedActivity.class);
                // intent.putExtra("type", 1);
                // startActivity(intent);
                // }
                // }, new OnBottomDialogListener() {
                //
                // @Override
                // public void onClicked() {
                // Intent intent = new Intent(
                // RedActivity.this,
                // ReceviedOrSendRedActivity.class);
                // intent.putExtra("type", 2);
                // startActivity(intent);
                // }
                // });
            }
        });

        findViewById(R.id.luck_tv).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Intent intent = new Intent(RedActivity.this, SendRedToGroupActivity.class);
                intent.putExtra("redType", 1);
                startActivityForResult(intent, 100);
            }
        });
        findViewById(R.id.ordinary_tv).setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Intent intent = new Intent(RedActivity.this, SendRedToGroupActivity.class);
                intent.putExtra("redType", 2);
                startActivityForResult(intent, 100);
            }
        });
        findViewById(R.id.back_layout).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 100 && resultCode == RESULT_OK) {
            forward_success_layout.setVisibility(View.VISIBLE);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    forward_success_layout.setVisibility(View.GONE);
                }
            }, 1000);
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        IMApplication.getInstance().removeActivity(this);
    }
}
